//index.js  
const Mock = require('mockjs');
const JSON5 = require('json5');
const path = require('path');
const fs = require('fs');
//读取json文件
function getJsonFile(filePath) {
    //读取json文件
    var json = fs.readFileSync(path.resolve(__dirname, filePath), 'utf-8');
    //将json对象转化成对象
    return JSON5.parse(json);
}

module.exports = function (app) {
    if (process.env.MOCK == 'true') {
        //接口1
        app.get('/api/address', (req, res) => {
            let json = getJsonFile('./json/address.json5');
            res.json(Mock.mock(json));
        });
    }
};